package com.example.demo.dao.mybatis;

import com.example.demo.entity.Account;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: 李浩然
 * @Date: 2021/5/10 10:49 上午
 */
@Repository
public interface AccountMapper {
    @Insert("insert into account(name,money) values(#{name},#{money})")
    int add(@Param("name") String name, @Param("money") double money);

    @Update("update account set name=#{name},money=#{money} where id=#{id}")
    int update(@Param("name") String name, @Param("money") double money, @Param("id") int id);

    @Delete("delete from account where id=#{id}")
    int delete(@Param("id") int id);

    @Select("select id ,name as name ,money as money from account where id=#{id}")
    Account findAccount(@Param("id") int id);

    @Select("select id,name as name,money as money from account")
    List<Account> findAccountList();
}